//
//  ViewController.m
//  XCDemo
//
//  Created by JanyGee on 2021/5/20.
//

#import "ViewController.h"
#import <CXGameKit/CXGameKit-Swift.h>

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *logLabel;
@property (weak, nonatomic) IBOutlet UITextField *moneyTextField;

@property (nonatomic, copy)NSString *uid;
@property (nonatomic, copy)NSString *token;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    /*
     channelId=1426
     adId=999095
     adFlag=aefa_1_0001
     appid=20399
     */
    
    [CXGameKit initWithSuccess:^{
        self.logLabel.text = @"初始化成功";
        } fail:^{
            self.logLabel.text = @"初始化失败";
        }];
}

- (IBAction)login:(id)sender {
    [CXGameKit loginWithLoginSuccess:^(NSDictionary<NSString *,NSString *> * _Nonnull res) {
        NSLog(@"=======%@", res);
        self.uid = res[@"uid"];
        self.token = res[@"token"];
    } loginFail:^{
        
    } logoutSuccess:^{
        
    } logoutFail:^{
        
    }];
}

- (IBAction)pay:(id)sender {
    [self.moneyTextField resignFirstResponder];
    
    [CXGameKit shopWithOrderAmount:self.moneyTextField.text subject:@"好东西" roleID:@"1111" roleLevel:@"100" roleName:@"小米" remark:@"lajjglll" cpBillNo:@"ssadsadas" uid:self.uid serverId:@"223" extraInfo:@"dsadsad" success:^{
            NSLog(@"=======支付成功");
        } fail:^{
            NSLog(@"=======支付失败");
        }];
}

- (IBAction)sendInfor:(id)sender {
    [CXGameKit submitWithUid:self.uid gameServerId:@"1001" roleLev:@"33" roleName:@"gg" roleId:@"5452254" loginTimes:@"885" duration:@"8554" totalMoneys:@"855" totalPowers:@"87455" heroLevel:@"54" totalStars:@"8888" gameServerName:@"78777" token:self.token success:^{
        
    } fail:^{
        
    }];
}

- (IBAction)switchUser:(id)sender {
    [CXGameKit switchAccount];
}

- (IBAction)logout:(id)sender {
    [CXGameKit logout];
}

- (IBAction)logoutGame:(id)sender {
    [CXGameKit logoutGame];
}

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.moneyTextField resignFirstResponder];
}

@end
